<p>Test for <a href="https://bugs.webkit.org/show_bug.cgi?id=62320">bug 62320</a>: 
Emit an error event when a request to enter full-screen is rejected.</p>
<p>Tests that the document is still messaged if the element requesting full screen is removed before the event is generated.</p>
<script src="full-screen-test.js"></script>
<script>
function runTest() {
    waitForEventOnceAndEnd(document, 'webkitfullscreenchange', function() {
            consoleWrite("FAIL - entered full screen!"); 
    });

    waitForEventOnceAndEnd(document, 'webkitfullscreenerror', function() {
        consoleWrite("SUCCEED - did not enter full screen!");
    });

    if (window.testRunner)
        testRunner.setPopupBlockingEnabled(true);

    var div = document.createElement('div');
    document.documentElement.appendChild(div);
    consoleWrite("Added child element.")
    div.webkitRequestFullScreen();
    document.documentElement.removeChild(div);
    consoleWrite("Removed child element.")
}

runTest();
</script>
